package com.zzm.validate.web.injector;

import org.apache.commons.validator.Arg;
import org.apache.commons.validator.Field;
import org.apache.commons.validator.Form;
import org.apache.commons.validator.util.ValidatorUtils;

public class FieldValueInjector extends ArgInjector {

	
	public FieldValueInjector() {
		this.setInjectKey("field");
	}

	@Override
	public String inject(Object bean, Form form, Field field,
			Arg arg, String message) {
		if(!injectable(arg)) {
			return message;
		}
		String fieldValue = ValidatorUtils.getValueAsString(bean, field.getProperty());
		return this.inject(message, arg, fieldValue);
	}


}
